package com.gaoyi.crm.control.dialog;

import android.content.Context;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;

import com.gaoyi.crm.R;
import com.gaoyi.crm.databinding.DialogToastBinding;
import com.gaoyi.crm.util.AppUtil;


public class ToastDialog extends BaseFragmentDialog<DialogToastBinding> {

    private String msg;
    private int resId;

    public ToastDialog(Context context) {
        super(context);
    }

    public ToastDialog setIco(int resId) {
        this.resId = resId;
        return this;
    }

    public ToastDialog setMessage(String msg) {
        this.msg = msg;
        return this;
    }

    @Override
    public void initView() {
        mBinding.tvMsg.setText(msg);
        if (resId > 0) {
            ;mBinding.ivIco.setImageResource(resId);
            if (resId == R.drawable.ic_loading) {
                Animation anim = AnimationUtils.loadAnimation(AppUtil.getContext(), R.anim.progressbar);
                anim.start();
                ;mBinding.ivIco.startAnimation(anim);
            }
        } else {
            ;mBinding.ivIco.setVisibility(View.GONE);
        }
    }

    @Override
    protected DialogToastBinding getViewBinding() {
        return DialogToastBinding.inflate(getLayoutInflater());
    }

    @Override
    protected String getShowTag() {
        return CENTER;
    }
}
